<template>
	<view class="merchant">
		<block v-if="storeInfo">
			<view class="merchant-nav">
				<u-navbar
					:title="storeInfo.store_name"
					:is-back="false"
					:borderBottom="false"
					:title-color="isScroll?'#000':'#FFF'"
					:background="{backgroundColor: isScroll?'#FFF':'rgba(255,255,255,0)'}">
				</u-navbar>
			</view>
			<view class="merchant-swiper" :style="{marginTop: '-'+NavHeight+'px'}">
				<swiper class="merchant-swiper-box" :indicator-dots="true" :autoplay="true" :interval="5000" indicator-color="rgba(255,255,255,1)" indicator-active-color="#141414" :circular="true">
					<swiper-item v-for="(data,index) in storeInfo.slide_img" :key="index">
						<image :lazy-load="true"
							mode="aspectFill"
							:src="data.image"
							@click="preview('store_slide_img',data.image,data.link)">
						</image>
					</swiper-item>
				</swiper>
			</view>
			<view class="merchant-info">
				<view class="merchant-info-company">
					<image :lazy-load="true" class="company-avatar" :src="storeInfo.store_logo"></image>
					<view class="company-info">
						<view class="company-info-name">{{storeInfo.store_name}}</view>
						<view class="company-info-address">
							地址：{{storeInfo.province_name}}{{storeInfo.city_name}}{{storeInfo.area_name}}{{storeInfo.address}}
						</view>
					</view>
					<image :lazy-load="true" class="company-info-phone" 
						src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/merchant/icon1.png" @click="makePhoneCall">
					</image>
				</view>
				<view class="merchant-company-des">
					<u-read-more
						ref="storeInfoBrief"
						:toggle="true"
						show-height="160"
						open-text="收起"
						close-text="展开"
						text-indent="0"
						color="#000"
						:shadowStyle="{marginTop: '-100px',paddingTop: '100px',backgroundImage: 'linear-gradient(-180deg, rgba(255, 255, 255, 0) 0%, #fff 80%)'}">
						{{storeInfo.brief}}
					</u-read-more>
				</view>
				<view class="merchant-company-imgs">
					<image :lazy-load="true" v-for="(data,index) in storeInfo.store_img" :key="index" :src="data.image" mode="aspectFill" @click="preview('store_img',data.image)"></image>
				</view>
				<view class="merchant-company-btns" v-if="appid!='wx9f2da8a90bb750f7'">
					<view class="merchant-company-btns-item" @click="goStoreInfo">
						<image :lazy-load="true" src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/merchant/icon2.png"></image>
						查看门店
					</view>
					<button class="merchant-company-btns-item" open-type="share" @click="share(1)">
						<image :lazy-load="true" src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/merchant/icon3.png"></image>
						分享门店
					</button>
				</view>
				<!-- app 分享 -->
				<u-action-sheet 
					:list="appShareList" 
					v-model="showShareList" 
					@click="appShare"
					:tips="{text: '分享到'}"
					:cancel-btn="true" 
					border-radius="10">
				</u-action-sheet>
				<!-- app 分享 -->
			</view>
			<view class="merchant-gary" v-if="storeInfo.type==1 && appid!='wx9f2da8a90bb750f7'">
				<button hover-class="" class="invite" open-type="share" @click="share(2)">
					<image :lazy-load="true" src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/merchant/icon10.png"></image>
					<view class="invite-info">
						<view class="invite-tit">邀请有礼</view>
						<view class="invite-des">邀请好友，豪礼送不停</view>
					</view>
					<view class="invite-btn">立即邀请</view>
				</button>
			</view>
			<block v-for="(sortItem,sortIndex) in containSort" :key="sortIndex">
				<view class="merchant-gary" v-if="storeInfo.type!=1 && sortItem.type==1">
					<view class="merchant-test">
						<view class="merchant-test-left">
							<image :lazy-load="true" src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/merchant/pic1.png" @click="goPackageList"></image>
						</view>
						<view class="merchant-test-right">
							<image :lazy-load="true" src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/merchant/pic2.png" @click="goStyleTest"></image>
							<image :lazy-load="true" src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/merchant/pic3.png" @click="goDesignTest"></image>
						</view>
					</view>
					<view class="merchant-form">
						<view class="merchant-form-tit">{{storeInfo.type==2?'我家装修要花多少钱？':'0元获取全屋设计方案'}}</view>
						<view class="merchant-form-group">
							<view class="merchant-form-cell">
								<image :lazy-load="true" src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/merchant/icon4.png"></image>
								<view class="merchant-form-cell-text">
									<input type="text" placeholder="请输入您的地址" v-model="formData.city"/>
								</view>
							</view>
							<view class="merchant-form-cell">
								<image :lazy-load="true" src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/merchant/icon5.png"></image>
								<view class="merchant-form-cell-text">
									<input type="text" placeholder="请输入房屋面积" v-model="formData.area"/>
									<text class="unit">㎡</text>
								</view>
							</view>
							<view class="merchant-form-cell">
								<image :lazy-load="true" src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/merchant/icon6.png"></image>
								<view class="merchant-form-cell-text">
									<input type="text" placeholder="请输入房屋格局(如:1室,1厅,1卫,1阳台)" v-model="formData.house"/>
								</view>
							</view>
						</view>
						<view class="merchant-form-btn" @click="submit">立即报价</view>
					</view>
					<view class="merchant-server-process">
						<view class="merchant-server-process-tit">服务流程</view>
						<!-- 装修公司 -->
						<block v-if="storeInfo.type==2">
							<view class="merchant-server-list">
								<view class="merchant-server-item">
									<text class="server-item-index">1</text>
									<view class="server-item-name">在线预约</view>
									<image :lazy-load="true" src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/merchant/icon8.png"></image>
								</view>
								<view class="merchant-server-item">
									<text class="server-item-index">2</text>
									<view class="server-item-name">量房沟通</view>
									<image :lazy-load="true" src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/merchant/icon8.png"></image>
								</view>
								<view class="merchant-server-item">
									<text class="server-item-index">3</text>
									<view class="server-item-name">对比方案</view>
								</view>
							</view>
							<view class="merchant-server-list">
								<view class="merchant-server-item">
									<text class="server-item-index">4</text>
									<view class="server-item-name">签订合同</view>
									<image :lazy-load="true" src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/merchant/icon8.png"></image>
								</view>
								<view class="merchant-server-item">
									<text class="server-item-index">5</text>
									<view class="server-item-name">装修施工</view>
									<image :lazy-load="true" src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/merchant/icon8.png"></image>
								</view>
								<view class="merchant-server-item">
									<text class="server-item-index">6</text>
									<view class="server-item-name">竣工验收</view>
								</view>
							</view>
						</block>
						<!-- 定制企业 -->
						<block v-if="storeInfo.type==3">
							<view class="merchant-server-list custom">
								<view class="merchant-server-item">
									<text class="server-item-index">1</text>
									<view class="server-item-name">网上预约</view>
									<image :lazy-load="true" src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/merchant/icon8.png"></image>
								</view>
								<view class="merchant-server-item">
									<text class="server-item-index">2</text>
									<view class="server-item-name">上门量尺</view>
								</view>
							</view>
							<view class="merchant-server-list custom">
								<view class="merchant-server-item">
									<text class="server-item-index">3</text>
									<view class="server-item-name">签订合同</view>
									<image :lazy-load="true" src="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/merchant/icon8.png"></image>
								</view>
								<view class="merchant-server-item">
									<text class="server-item-index">4</text>
									<view class="server-item-name">产品配送</view>
								</view>
							</view>
						</block>
					</view>
				</view>
				<view class="skill" v-if="sortItem.type==9">
					<view class="skill-tit">
						<view class="count-down">
							<view class="label">低价秒杀</view>
							<!-- <u-count-down :timestamp="timestamp" bg-color="#F59359" color="#FFF" fontSize="24" height="40" separator-color="#F59359"></u-count-down> -->
						</view>
						<view class="more" @click="goSkillList">更多 <u-icon name="arrow-right" color="#808080"></u-icon></view>
					</view>
					<view class="skill-items">
						<view class="skill-item" v-for="(data,index) in skillList" :key="index" @click="goMerchantProInfo(data)">
							<image :src="data.image"></image>
							<view class="price">￥<text>{{data.activity_price}}</text></view>
							<view class="sub-price">￥{{data.retail_price}}</view>
						</view>
					</view>
				</view>
				<!-- 品牌推荐模板 -->
				<view class="index-brand" v-if="sortItem.type==8">
					<pt-title
						name="品牌推荐"
						subName=" "
						:isRight="false">
					</pt-title>
					<view class="index-brand-list">
						<view class="shadow">
							<view class="index-brand-tabs">
								<view
									:class="['index-brand-tabs-item',{active: brandIndex==bIndex}]"
									v-for="(item,bIndex) in brandSort" 
									:key="bIndex"
									@click="changeBrandType(bIndex,item.class_id)">
									{{item.class_name}}
								</view>
							</view>
							<pt-brand-list :list="brandList" v-if="brandList.length"></pt-brand-list>
							<pt-nothing text="暂无数据" bgColor="#FFFFFF" v-if="!brandList.length"></pt-nothing>
						</view>
					</view>
				</view>
				<view class="merchant-prolist" v-if="sortItem.type==2">
					<pt-title name="自营商品" :isRight="false"></pt-title>
					<view style="margin-top: -50rpx;">
						<u-tabs
							:list="storeGoodsClassList"
							:current="storeGoodsClassIndex"
							@change="storeGoodsClassTabChange"
							active-color="#141414"
							inactive-color="#666666"
							name="class_name"
							font-size="28">
						</u-tabs>
					</view>
					<view style="padding: 0 30rpx;">
						<pt-product-items
							:showSort="false"
							:object="{goods_list: storeGoodsList}"
							:isMerchant="true"
							:noMore="true"
							@GoInfoAddFoot="GoInfoAddFoot(1,$event)"
							:isLogin="isLogin">
						</pt-product-items>
						<pt-nothing text="暂无商品" v-if="!storeGoodsList.length" bgColor="#FFF"></pt-nothing>
					</view>
					<pt-scroll-more
						:text="'探索更多'"
						:icon="'https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/index/arrow-orange.png'"
						:width="16"
						:height="22"
						:isBox="true"
						@Func="goMerchantProList"
						style="margin-top: 80rpx;"
						v-if="storeGoodsList.length">
					</pt-scroll-more>
				</view>
				<view class="merchant-cases" v-if="sortItem.type==3">
					<pt-title name="优选案例" @more="merchantMoreCase"></pt-title>
					<u-tabs
						:list="storeCaseClassList"
						:current="storeCaseIndex"
						active-color="#141414"
						inactive-color="#666666"
						font-size="28"
						name="style_name"
						@change="storeCaseTabChange"
						style="margin-top: -50rpx;">
					</u-tabs>
					<pt-case :list="storeCaseList" :showAttr="true" @goInfo="goCaseInfo"></pt-case>
					<pt-nothing text="暂无案例" bgColor="#FFF" v-if="!storeCaseList.length" :isHigh="true"></pt-nothing>
				</view>
				<view class="merchant-team" v-if="sortItem.type==4">
					<pt-title name="设计团队" @more="merchantMoreTeam" padding="140rpx 30rpx 88rpx"></pt-title>
					<view :class="['merchant-team-list',{less: storeTeam.length < 3}]">
						<pt-design-item v-for="(data,index) in storeTeam" :key="index" :item="data" @click="goTeamInfo(data.store_stylist_id)"></pt-design-item>
					</view>
					<pt-nothing text="暂无团队" bgColor="#FFF" v-if="!storeTeam.length"></pt-nothing>
				</view>
				<view class="merchant-package" v-if="sortItem.type==5">
					<pt-title name="优选套餐" @more="merchantMorePackage" padding="30rpx 30rpx 80rpx"></pt-title>
					<view class="merchant-package-list">
						<pt-product-items
							:showSort="false"
							:isBig="true"
							mode="aspectFill"
							:object="{goods_list: storePackList}"
							:isMerchant="true"
							:isPack="true"
							@GoInfoAddFoot="GoInfoAddFoot(2,$event)"
							:isLogin="isLogin">
						</pt-product-items>
					</view>
				</view>
				<view class="merchant-video" v-if="!isReview && sortItem.type==6">
					<pt-title name="视频分享" @more="merchantMoreVideo"></pt-title>
					<view class="merchant-video-list">
						<pt-var
							:list="storeVideoList"
							@Func="goVideoInfo"
							:show-icon="true"
							:isVideo="true"
							icon="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/merchant/icon9.png">
						</pt-var>
					</view>
					<pt-nothing text="暂无视频" bgColor="#FFF" v-if="!storeVideoList.length"></pt-nothing>
				</view>
				<view class="merchant-platform-prolist" v-if="sortItem.type==7">
					<pt-title name="总部商品" :isRight="false"></pt-title>
					<view style="margin-top: -50rpx;">
						<u-tabs
							:list="storePlatformClassList"
							:current="storePlatformClassIndex"
							@change="storePlatformClassTabChange"
							active-color="#141414"
							inactive-color="#666666"
							name="class_name"
							font-size="28">
						</u-tabs>
					</view>
					<view style="padding: 0 30rpx;">
						<pt-product-items
							:showSort="false"
							:object="{goods_list: storePlatformGoodsList}"
							@GoInfoAddFoot="GoInfoAddFoot(3,$event)"
							:isLogin="isLogin">
						</pt-product-items>
					</view>
				</view>
			</block>
			<pt-loading-more v-if="isLoading"></pt-loading-more>
			<pt-nomore v-if="noMore && storePlatformGoodsList.length"></pt-nomore>
		</block>
		<block v-if="show && !storeInfo">
			<pt-nothing text="请登录查看" fixed showLogin></pt-nothing>
		</block>
		<uni-popup type="center" ref="server">
			<pt-server></pt-server>
		</uni-popup>
		<u-tabbar :list="tabbarList" :icon-size="44" :height="100"></u-tabbar>
		<pt-loading></pt-loading>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isReview: false,
				tabbarList: [],
				showHome: false,
				show: false,
				isScroll: false,
				statusBarHeight: 0,
				merchantHeaderHeight: 0,
				menuButtonInfo: '',
				systemInfo: '',
				storeInfo: '',
				merchantSwiperHeight: 300,
				// 分享
				showShareList: false,
				appShareList: [{
					text: '分享给微信朋友'
				},{
					text: '分享到微信朋友圈'
				}],
				merchantVideoList: [],
				NavHeight: 0,
				// 自营商品参数
				showPro: false,
				class_id: '',
				storeGoodsClassList: [],
				storeGoodsClassIndex: 0,
				storeGoodsList: [],
				// 优选案例
				showCases: false,
				style_id: '',
				storeCaseClassList: [],
				storeCaseIndex: 0,
				storeCaseList: [],
				// 设计团队
				storeTeam: [],
				// 优选套餐
				storePackList: [],
				// 视频
				storeVideoList: [],
				// 总部商品
				page: 0,
				storePlatformClassList: [],
				storePlatformClassIndex: 0,
				storePlatformGoodsList: [],
				platform_class_id: '',
				isLoading: false,
				noMore: false,
				formData: {
					city: '',
					area: '',
					house: '',
					phone: uni.getStorageSync('userInfo')?JSON.parse(uni.getStorageSync('userInfo')).phone:''
				},
				Refresh: false,
				showPlatformGoods: false,
				parent_id: '',
				appid: '',
				// 足迹参数
				addFootParam: {
					start_time: '',
					end_time: '',
					stay_time: 0
				},
				containSort: [{
					type: 1
				},{
					type: 8
				},{
					type: 2
				},{
					type: 3
				},{
					type: 4
				},{
					type: 5
				},{
					type: 6
				},{
					type: 7
				}],
				brandIndex: 0,
				brandSort: [],
				brandList: [],
				skillList: [],
				timestamp: 0,
				kill_id: '',
				isLogin: false
			};
		},
		onPullDownRefresh() {
			this.Refresh = true
			this.show = false
			this.page = 0
			this.noMore = false
			this.storePlatformGoodsList = []
			setTimeout(() => {
				if(uni.getStorageSync('userInfo')){
					this.isLogin = true
					this.init()
				}else{
					this.isLogin = false
				}
				this.getHome()
			},500)
		},
		onLoad(options) {
			// #ifdef MP-WEIXIN
			this.appid = uni.getExtConfigSync().appid
			// #endif
			this.isReview = uni.getStorageSync('review')
			if(options.parent_id){
				this.parent_id = options.parent_id
				uni.setStorageSync('parent_id',options.parent_id)
				// 如果用户从分享的小程序卡片点击进来的,设置一个url缓存,登录后返回当前缓存url
				let pages = getCurrentPages();
				let curPage = pages[pages.length - 1];
				uni.setStorageSync('newurl',curPage.$page.fullPath)
				this.$u.api.binding_refer({id: options.parent_id}).catch(() => {
					console.log('接口报错：绑定失败')
				})
			}
			if(uni.getStorageSync('userInfo')){
				this.addFoot('主页')
			}
		},
		onShow() {
			if(uni.getStorageSync('userInfo')){
				this.isLogin = true
				this.init()
			}else{
				this.show = true
			}
			this.getHome()
			// #ifdef MP || APP-PLUS
			setTimeout(() => {
				uni.setNavigationBarColor({
					frontColor: '#ffffff',
					backgroundColor: '',
					animation: {
						duration: 400,
						timingFunc: 'easeIn'
					}
				})
			},200)
			// #endif
			// 解决部分机型点击分享卡片进入不会重新执行绑定的问题
			if(this.parent_id){
				this.$u.api.binding_refer({id: this.parent_id}).catch(() => {
					console.log('接口报错：绑定失败')
				})
			}
		},
		onReady() {
			if(uni.getStorageSync('tabbarIconsBefore')){
				this.tabbarList[0].iconPath = uni.getStorageSync('tabbarIconsBefore').img1
				this.tabbarList[1].iconPath = uni.getStorageSync('tabbarIconsBefore').img2
				this.tabbarList[2].iconPath = uni.getStorageSync('tabbarIconsBefore').img3
				this.tabbarList[3].iconPath = uni.getStorageSync('tabbarIconsBefore').img4
				this.tabbarList[4].iconPath = uni.getStorageSync('tabbarIconsBefore').img5
			}
			if(uni.getStorageSync('tabbarIcons')){
				if(uni.getStorageSync('tabbarIcons').img3){
					this.tabbarList[2].selectedIconPath = uni.getStorageSync('tabbarIcons').img3
				}
			}
		},
		methods: {
			// 获取秒杀商品
			async getSkill(){
				const { datas } = await this.$u.api.StoreGoodsList({
					store_id: uni.getStorageSync('userInfo')?JSON.parse(uni.getStorageSync('userInfo')).store_id:1,
					limit: 3,
					goods_type: 4
				})
				if(datas.length){
					this.skillList = datas
				}
			},
			// 跳转秒杀列表
			goSkillList(){
				uni.navigateTo({
					animationDuration: 500,
					url: '/merchant/store-skill/store-skill'
				})
			},
			// 跳转秒杀商品详情
			goMerchantProInfo(data){
				uni.navigateTo({
					animationDuration: 500,
					url: '/pages/product-info/product-info?isMerchant=ture&goods_id='+data.store_goods_id
				})
			},
			getHome(){
				// 获取是否显示商户主页
				if(uni.getStorageSync('userInfo')){
					if(uni.getStorageSync('is_open')){
						this.tabbarList = getApp().globalData.arrowMerchantMenu
					}else{
						// #ifdef MP-WEIXIN
						if(uni.getExtConfigSync().appid==='wx9f2da8a90bb750f7'){
							this.tabbarList = getApp().globalData.merchantMenu.slice(1)
						}else{
							this.tabbarList = getApp().globalData.merchantMenu
						}
						// #endif
						// #ifdef APP-PLUS || H5
						this.tabbarList = getApp().globalData.merchantMenu
						// #endif
					}
					this.$u.api.ShowHome().then(res => {
						let userInfo = JSON.parse(uni.getStorageSync('userInfo'))
						if(userInfo.store_id!=res.datas.store_id){
							userInfo.store_id = res.datas.store_id
							userInfo.store_name = res.datas.store_name
						}
						uni.setStorageSync('userInfo',JSON.stringify(userInfo))
						if(res.datas.is_open==1){
							this.tabbarList = getApp().globalData.arrowMerchantMenu
							uni.setStorageSync('is_open',true)
						}else{
							uni.setStorageSync('is_open',false)
							// #ifdef MP-WEIXIN
							if(uni.getExtConfigSync().appid==='wx9f2da8a90bb750f7'){
								this.tabbarList = getApp().globalData.merchantMenu.slice(1)
							}else{
								this.tabbarList = getApp().globalData.merchantMenu
							}
							// #endif
							// #ifdef APP-PLUS || H5
							this.tabbarList = getApp().globalData.merchantMenu
							// #endif
						}
					})
					this.$u.api.UserNoticeCount().then(res => {
						if(res.datas){
							this.$set(this.tabbarList[this.tabbarList.length-1],'count',res.datas)
						}else{
							this.$set(this.tabbarList[this.tabbarList.length-1],'count',res.datas)
						}
					})
				}else{
					// #ifdef MP-WEIXIN
					if(uni.getExtConfigSync().appid==='wx9f2da8a90bb750f7'){
						this.tabbarList = getApp().globalData.arrowDefaultMenu
					}else{
						this.tabbarList = getApp().globalData.defaultMenu
					}
					// #endif
					// #ifdef APP-PLUS || H5
					this.tabbarList = getApp().globalData.defaultMenu
					// #endif
				}
			},
			async init(){
				const { datas } = await this.$u.api.GetIndexSort({
					store_id: uni.getStorageSync('userInfo')?JSON.parse(uni.getStorageSync('userInfo')).store_id:1
				})
				this.containSort = datas
				let data = {
					paramter: 1,
					store_id: uni.getStorageSync('userInfo')?JSON.parse(uni.getStorageSync('userInfo')).store_id:1
				}
				this.$u.api.StoreInfo(data).then(res => {
					this.storeInfo = res.datas[0]
					let user_id = uni.getStorageSync('userInfo')?JSON.parse(uni.getStorageSync('userInfo')).user_id:''
					this.$u.mpShare = {
						title: this.storeInfo.store_data.share_txt,
						path: '/pages/merchant/merchant?parent_id=' + user_id,
						imageUrl: this.storeInfo.store_data.share_images
					}
					uni.setNavigationBarTitle({
						title: res.datas[0].store_name
					})
				}).then(res => {
					this.$nextTick(() => {
						this.getHeaderHeight()
						this.$refs.storeInfoBrief.init()
					})
					let obj = {
						client: 6,
						asc: 2,
						is_online: 1,
						store_id: uni.getStorageSync('userInfo')?JSON.parse(uni.getStorageSync('userInfo')).store_id:1
					}
					this.$u.api.SlideShowList(obj).then(slideRes => {
						this.$set(this.storeInfo,'slide_img',slideRes.datas)
					})
					this.getSkill()
					this.getMerchantPro()
					this.getMerchantCase()
					this.getStoreTeam()
					this.getStorePack()
					this.getStoreVideo()
					this.getPlatformClass()
					this.getPlatformGoods()
					this.getPlatformFactoryClassList()
					if(this.Refresh){
						this.Refresh = false
						uni.stopPullDownRefresh({
							success: () => {
								uni.showToast({
									icon: 'none',
									title: '刷新成功'
								})
							}
						})
					}
				})
			},
			// 品牌分类
			async getPlatformFactoryClassList(){
				const {datas} = await this.$u.api.PlatformFactoryClassList({
					store_id: this.storeInfo.store_id
				})
				this.brandSort = datas
				if(this.brandSort.length){
					this.getPlatformFactoryLists(this.brandSort[0].class_id)
				}
			},
			// 选择品牌类型
			changeBrandType(e,class_id){
				this.brandIndex = e
				this.getPlatformFactoryLists(class_id)
			},
			async getPlatformFactoryLists(class_id){
				const {datas} = await this.$u.api.PlatformFactoryLists({
					store_id: this.storeInfo.store_id,
					class_id: class_id
				})
				this.brandList = datas.list
			},
			// 自营商品相关
			getMerchantPro(){
				this.$u.api.StoreGoodsList({
					type: 1,
					limit: 10,
					store_id: this.storeInfo.store_id,
					class_id: this.class_id
				}).then(res => {
					if(res.datas.length){
						this.showPro = true
					}
					this.storeGoodsList = res.datas
				})
				this.$u.api.StoreGoodsClassList({
					limit: 100,
					status: 1,
					type: 1,
					store_id: this.storeInfo.store_id
				}).then(res => {
					this.storeGoodsClassList = res.datas
					this.storeGoodsClassList.unshift({
						class_name: '全部',
						class_id: ''
					})
				})
			},
			storeGoodsClassTabChange(e){
				this.storeGoodsClassIndex = e
				this.class_id = this.storeGoodsClassList[e].class_id
				this.getMerchantPro()
			},
			// 优选案例相关
			getMerchantCase(){
				this.$u.api.CaseList({
					limit: 2,
					style_id: this.style_id,
					store_id: this.storeInfo.store_id
				}).then(res => {
					if(!this.storeCaseClassList.length){
						this.storeCaseClassList = res.datas.style_list
					}
					if(res.datas.list.length){
						this.showCases = true
					}
					this.storeCaseList = res.datas.list
				})
			},
			storeCaseTabChange(e){
				this.storeCaseIndex = e
				this.style_id = this.storeCaseClassList[e].style_id
				this.getMerchantCase()
			},
			// 设计团队相关
			getStoreTeam(){
				this.$u.api.StylistList({
					limit: 6,
					store_id: this.storeInfo.store_id
				}).then(res => {
					this.storeTeam = res.datas
				})
			},
			// 优选套餐
			getStorePack(){
				this.$u.api.StoreGoodsList({
					type: 2,
					limit: 3,
					store_id: this.storeInfo.store_id
				}).then(res => {
					this.storePackList = res.datas
				})
			},
			// 视频列表
			getStoreVideo(){
				this.$u.api.storeVideoList({
					limit: 3,
					store_id: this.storeInfo.store_id
				}).then(res => {
					this.storeVideoList = res.datas
				})
			},
			// 总部商品
			getPlatformClass(){
				this.$u.api.PlatformClassList({
					limit: 100,
					store_id: this.storeInfo.store_id
				}).then(res => {
					this.storePlatformClassList = res.datas
					this.storePlatformClassList.unshift({
						class_name: '全部',
						platform_class_id: ''
					})
				})
			},
			getPlatformGoods(){
				this.$u.api.PlatformGoodsLists({
					store_id: this.storeInfo.store_id,
					limit: 10,
					page: this.page,
					status: 1,
					platform_class_id: this.platform_class_id
				}).then(res => {
					this.isLoading = false
					if(res.datas.length){
						this.showPlatformGoods = true
						res.datas.forEach(item => {
							this.storePlatformGoodsList.push(item)
						})
					}else{
						this.noMore = true
					}
				})
			},
			storePlatformClassTabChange(e){
				this.noMore = false
				this.page = 0
				this.storePlatformGoodsList = []
				this.storePlatformClassIndex = e
				this.platform_class_id = this.storePlatformClassList[e].platform_class_id
				this.getPlatformGoods()
			},
			// 商户主页
			getHeaderHeight(){
				uni.createSelectorQuery().in(this).select('.merchant-nav').boundingClientRect(res => {
					this.NavHeight = res.height
				}).exec()
			},
			// 图片预览
			preview(type,current,link){
				if(link){
					uni.navigateTo({
						animationDuration: 500,
						url: link
					})
					return
				}
				let urls = []
				switch (type){
					case 'store_slide_img':
						this.storeInfo.slide_img.forEach(item => {
							urls.push(item.image)
						})
						break;
					case 'store_img':
						this.storeInfo.store_img.forEach(item => {
							urls.push(item.image)
						})
						break;
				}
				uni.previewImage({
					current: current,
					urls: urls
				})
			},
			makePhoneCall(){
				uni.makePhoneCall({
					phoneNumber: this.storeInfo.store_service_phone
				})
			},
			share(type){
				// #ifdef APP-PLUS
				this.showShareList = true
				// #endif
				// #ifdef H5
				let url = 'https://master.jiaju01.com/web/shop/#/pages/merchant/merchant?parent_id='+this.storeInfo.user_id
				uni.setClipboardData({
					data: url,
					success: () => {
						uni.showToast({
							icon: 'none',
							title: '链接复制成功，赶紧发送给朋友吧~'
						})
					}
				})
				// #endif
				if(uni.getStorageSync('userInfo')){
					if(type==1){
						this.addFoot('主页-分享门店','#客户分享了门店，请注意保持跟进')
					}else if(type==2){
						this.addFoot('主页-邀请有礼','#客户分享了门店给朋友，挺认可贵公司的，可以重点跟进')
					}
				}
			},
			appShare(index){
				switch (Number(index)){
					case 0:
						uni.share({
							provider: "weixin",
							scene: "WXSceneSession",
							type: 5,
							imageUrl: this.storeInfo.store_data.share_images, // this.storeInfo.store_data.share_images
							title: this.storeInfo.store_data.share_txt,
							miniProgram: {
								id: 'gh_acfd003d4328',
								path: '/pages/merchant/merchant?parent_id=' + this.storeInfo.user.user_id,
								type: 0,
								webUrl: 'https://master.jiaju01.com/web/shop/#/pages/merchant/merchant?parent_id='+this.storeInfo.user.user_id,
							},
							success: (res) => {
								console.log('分享成功')
							},
							fail: (fail) => {
								console.log(res)
							}
						});
						break;
					case 1:
						uni.share({
							provider: "weixin",
							scene: "WXSenceTimeline",
							type: 0,
							title: this.storeInfo.store_data.share_txt,
							imageUrl: this.storeInfo.store_logo,
							href: 'https://master.jiaju01.com/web/shop/#/pages/merchant/merchant?parent_id='+this.storeInfo.user.user_id,
							success: (res) => {
								console.log('分享成功')
							},
							fail: (fail) => {
								console.log(res)
							}
						})
						break;
				}
			},
			// goProInfo(goods_id){
			// 	getApp().goProInfo(goods_id)
			// },
			goMerchantProList(){
				uni.navigateTo({
					animationDuration: 500,
					url: '/merchant/store-pro/store-pro'
				})
				if(uni.getStorageSync('userInfo')){
					this.addFoot('主页-自营商品-列表','#客户查看了自营商品，建议给客户推荐相关热销商品')
				}
			},
			merchantMoreCase(){
				uni.navigateTo({
					animationDuration: 500,
					url: '/pages/case-list/case-list?store_id='+this.storeInfo.store_id
				})
				if(uni.getStorageSync('userInfo')){
					this.addFoot('主页-案例-列表','#客户查看了案例，对贵公司做过的案例感兴趣')
				}
			},
			goCaseInfo(e){
				uni.navigateTo({
					animationDuration: 500,
					url: '/pages/case-list/case-details/case-details?case_id=' + e
				})
				if(uni.getStorageSync('userInfo')){
					this.addFoot('主页-案例-详情','#客户查看了案例，对贵公司做过的案例感兴趣')
				}
			},
			merchantMoreTeam(){
				uni.navigateTo({
					animationDuration: 500,
					url: '/merchant/store-team/store-team'
				})
				if(uni.getStorageSync('userInfo')){
					this.addFoot('主页-设计师-列表','#客户查看了设计师，对贵公司设计师团队感兴趣')
				}
			},
			merchantMorePackage(){
				uni.navigateTo({
					animationDuration: 500,
					url: '/merchant/store-pack/store-pack'
				})
				if(uni.getStorageSync('userInfo')){
					this.addFoot('主页-套餐-列表','#客户查看了套餐，对贵公司的套餐感兴趣')
				}
			},
			merchantMoreVideo(){
				uni.navigateTo({
					animationDuration: 500,
					url: '/merchant/store-video/store-video'
				})
				if(uni.getStorageSync('userInfo')){
					this.addFoot('主页-视频-列表','#客户查看了视频，对贵公司的视频感兴趣')
				}
			},
			goVideoInfo(e){
				uni.navigateTo({
					animationDuration: 500,
					url: '/merchant/store-video/store-video-info?video_id=' + e
				})
				if(uni.getStorageSync('userInfo')){
					this.addFoot('主页-视频-详情','#客户查看了视频，对贵公司的视频感兴趣')
				}
			},
			goStoreInfo(){
				uni.navigateTo({
					animationDuration: 500,
					url: '/merchant/store-info/store-info?store_id='+this.storeInfo.store_id
				})
				if(uni.getStorageSync('userInfo')){
					this.addFoot('主页-查看门店','#客户查看了门店，最近可能有到店计划，请注意保持跟进')
				}
			},
			goTeamInfo(stylist_id){
				uni.navigateTo({
					animationDuration: 500,
					url: '/merchant/store-team/store-team-info?stylist_id='+stylist_id
				})
				if(uni.getStorageSync('userInfo')){
					this.addFoot('主页-设计师-详情','#客户查看了设计师，对贵公司设计师团队感兴趣')
				}
			},
			inputCustomer(e,name){
				this.formData[name] = e.detail.value
			},
			submit(){
				if(!this.formData.city){
					uni.showToast({
						icon: 'none',
						title: '请输入您所在的城市'
					})
					return false
				}else if(!this.formData.area){
					uni.showToast({
						icon: 'none',
						title: '请输入房屋面积'
					})
					return false
				}else if(!this.formData.house){
					uni.showToast({
						icon: 'none',
						title: '请输入房屋格局'
					})
					return false
				}
				this.$u.api.StoreCustomer({
					type: 1,
					store_id: this.storeInfo.store_id,
					city: this.formData.city,
					area: this.formData.area,
					house: this.formData.house,
					phone: this.formData.phone
				}).then(res => {
					uni.showToast({
						icon: 'none',
						title: res.datas
					})
					this.formData = this.$options.data().formData
					this.$refs.server.open()
				})
			},
			goPackageList(){
				uni.navigateTo({
					animationDuration: 500,
					url: '/pages/package/package?type=2'
				})
			},
			goStyleTest(){
				uni.navigateTo({
					animationDuration: 500,
					url: '/merchant/store-style/store-style-1'
				})
			},
			goDesignTest(){
				uni.navigateTo({
					animationDuration: 500,
					url: '/merchant/store-design/store-design'
				})
			},
			addFoot(where,detail,goods_id){
				this.$u.api.AddFoot({
					// #ifdef MP-WEIXIN
					type: 1,
					// #endif
					// #ifdef APP-PLUS
					type: 2,
					// #endif
					// #ifdef H5
					type: 3,
					// #endif
					store_id: uni.getStorageSync('userInfo')?JSON.parse(uni.getStorageSync('userInfo')).store_id:'',
					client: 1,
					where: where,
					stay_time: this.addFootParam.stay_time,
					goods_id: 0,
					store_goods_id: goods_id?goods_id:0,
					is_new: 1,
					detail: detail?detail:''
				})
			},
			GoInfoAddFoot(type,goods_id){
				if(uni.getStorageSync('userInfo')){
					switch (Number(type)){
						case 1:
							this.addFoot('主页-自营商品-详情','#客户查看了自营商品，建议给客户推荐相关热销商品',goods_id)
							break;
						case 2:
							this.addFoot('主页-套餐-详情','#客户查看了套餐，对贵公司的套餐感兴趣',goods_id)
							break;
						case 3:
							this.addFoot('主页-总部商品-详情','#客户查看了总部商品，建议给客户推荐相关热销商品',goods_id)
							break;
					}
				}
			}
		},
		onPageScroll(e) {
			if(e.scrollTop > 100){
				this.isScroll = true
				// #ifdef MP
				uni.setNavigationBarColor({
					frontColor: '#000000',
					backgroundColor: ''
				})
				// #endif
				// #ifdef APP-PLUS
				plus.navigator.setStatusBarStyle("dark")
				// #endif
			}else{
				this.isScroll = false
				// #ifdef MP
				uni.setNavigationBarColor({
					frontColor: '#ffffff',
					backgroundColor: ''
				})
				// #endif
				// #ifdef APP-PLUS
				plus.navigator.setStatusBarStyle("light")
				// #endif
			}
		},
		onReachBottom() {
			if(!this.noMore){
				this.page++
				this.isLoading = true
				this.getPlatformGoods()
			}
		}
	}
</script>

<style lang="scss">
	.merchant{
		.merchant-header{
			position: fixed;
			text-align: center;
			color: #FFF;
			font-size: 38rpx;
			font-weight: bold;
			left: 0;
			top: 0;
			z-index: 2;
			transition: all .5s;
		}
		.merchant-swiper{
			.merchant-swiper-box{
				height: 600rpx;
			}
			image{
				width: 100%;
				height: 600rpx;
			}
		}
		.merchant-info{
			padding: 60rpx 30rpx;
			.merchant-info-company{
				display: flex;
				align-items: center;
				margin-bottom: 50rpx;
				.company-avatar{
					width: 96rpx;
					height: 96rpx;
					border-radius: 50%;
					border: solid 2rpx #EEE;
				}
				.company-info{
					flex: 1;
					min-width: 0;
					margin: 0 30rpx;
					.company-info-name{
						color: #000;
						font-size: 36rpx;
						font-weight: bold;
						margin-bottom: 10rpx;
					}
					.company-info-address{
						color: #757575;
						font-size: 22rpx
					}
				}
				.company-info-phone{
					width: 42rpx;
					height: 42rpx;
				}
			}
		}
		.merchant-company-imgs{
			display: flex;
			align-items: flex-start;
			justify-content: space-between;
			margin-top: 40rpx;
			image{
				width: 216rpx;
				height: 216rpx;
				border-radius: 4rpx;
			}
		}
		.merchant-company-btns{
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-top: 50rpx;
			.merchant-company-btns-item{
				display: flex;
				align-items: center;
				justify-content: center;
				width: 320rpx;
				height: 80rpx;
				background:rgba(248,248,248,1);
				border-radius:8px;
				font-size: 28rpx;
				color: #141414;
				font-weight: bold;
				&::after{
					display: none;
				}
				image{
					width: 32rpx;
					height: 32rpx;
					margin-right: 18rpx;
				}
			}
		}
		.merchant-gary{
			background-color: #f6f6f6;
			padding: 30rpx;
			.merchant-test{
				display: flex;
				align-items: flex-start;
				justify-content: space-between;
				.merchant-test-left{
					width: 337rpx;
					image{
						width: 337rpx;
						height: 422rpx;
					}
				}
				.merchant-test-right{
					width: 336rpx;
					image{
						width: 336rpx;
						height: 200rpx;
						&:first-child{
							margin-bottom: 20rpx;
						}
					}
				}
			}
			.merchant-form{
				background-color: #FFF;
				padding: 50rpx 30rpx;
				border-radius: 8rpx;
				margin-top: 40rpx;
				.merchant-form-tit{
					text-align: center;
					font-size: 36rpx;
					color: #141414;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
					font-weight: bold;
				}
				.merchant-form-group{
					margin-top: 40rpx;
					.merchant-form-cell{
						display: flex;
						align-items: center;
						border-bottom: solid 2rpx #F2F2F2;
						height: 120rpx;
						image{
							width: 36rpx;
							height: 36rpx;
							margin-right: 30rpx;
						}
						.merchant-form-cell-text{
							flex: 1;
							min-width: 0;
							display: flex;
							input{
								flex: 1;
								min-width: 0;
								font-size: 32rpx;
								color: #141414;
							}
						}
					}
				}
				.merchant-form-btn{
					height: 90rpx;
					line-height: 90rpx;
					text-align: center;
					background-color: #F59359;
					color: #FFF;
					font-size: 32rpx;
					font-weight: bold;
					border-radius: 8rpx;
					margin: 50rpx 20rpx 0;
				}
			}
			.merchant-server-process{
				margin-top: 30rpx;
				background-color: #FFF;
				padding: 30rpx;
				border-radius: 8rpx;
				.merchant-server-process-tit{
					font-size: 36rpx;
					text-align: center;
					font-weight: bold;
					color: #141414;
				}
				.merchant-server-list{
					display: flex;
					flex-wrap: wrap;
					justify-content: space-between;
					&:last-child{
						padding-bottom: 20rpx;
					}
					.merchant-server-item{
						display: flex;
						align-items: center;
						font-size: 28rpx;
						color: #141414;
						margin-top: 60rpx;
						font-weight: bold;
						position: relative;
						image{
							position: absolute;
							width: 80rpx;
							height: 21rpx;
							right: -90rpx;
						}
						.server-item-index{
							font-style: italic;
							margin-right: 15rpx;
							color: #A3A3A3;
						}
					}
					&.custom{
						.merchant-server-item{
							width: 50%;
							text-align: center;
							image{
								right: 45rpx;
							}
						}
					}
				}
			}
			.invite{
				display: flex;
				align-items: center;
				background-color: #FFF;
				height: 170rpx;
				line-height: normal;
				image{
					width: 88rpx;
					height: 88rpx;
				}
				.invite-info{
					flex: 1;
					min-width: 0;
					margin: 0 20rpx;
					text-align: left;
					.invite-tit{
						font-size: 32rpx;
						color: #141414;
					}
					.invite-des{
						color: #767676;
						font-size: 22rpx;
						margin-top: 10rpx;
					}
				}
				&::after{
					display: none;
				}
				.invite-btn{
					width: 180rpx;
					height: 80rpx;
					background:rgba(248,248,248,1);
					border-radius: 8rpx;
					line-height: 80rpx;
					text-align: center;
					font-size: 28rpx;
					font-weight: bold;
					color: #141414;
				}
			}
		}
		/deep/ .merchant-prolist{
			.product-items{
				border-bottom: none;
			}
		}
		.merchant-team-list{
			padding: 0 30rpx;
			display: flex;
			flex-direction: column;
			flex-wrap: wrap;
			/* #ifdef MP || H5 */
			height: 658rpx;
			/* #endif */
			/* #ifdef APP-PLUS */
			height: 658rpx;
			/* #endif */
			overflow-x: auto;
			-webkit-overflow-scrolling: touch;
			/deep/ .design-item{
				width: 590rpx;
				.design-item-right{
					margin-right: 30rpx;
				}
			}
			&.less{
				display: block;
				height: auto;
				/deep/ .design-item{
					width: 100%;
					&:last-child{
						margin-bottom: 30rpx;
					}
					.design-item-right{
						margin-right: 0;
					}
				}
			}
		}
		.merchant-package{
			.merchant-package-list{
				padding: 0 30rpx;
				/deep/ .product-items{
					border-bottom: none;
				}
				/deep/ .product-items-list-item image{
					height: 550rpx;
					border-radius: 8rpx 8rpx 0px 0px;
				}
				/deep/ .product-items-list-item{
					margin-top: 0;
					box-shadow: 0px 20rpx 40rpx 0px rgba(40,34,31,0.05);
					border-radius: 0px 0px 8rpx 8rpx;
					margin-bottom: 60rpx;
					&:last-child{
						margin-bottom: 0;
					}
				}
			}
		}
		.merchant-platform-prolist{
			/deep/ .product-items{
				border-bottom: none;
			}
		}
		.index-brand-list{
			padding: 0 30rpx 40rpx;
			.shadow{
				box-shadow: 0rpx 20rpx 40rpx 0 rgba(40,34,31,0.05);
			}
			.index-brand-tabs{
				display: flex;
				.index-brand-tabs-item{
					flex: 1;
					height: 90rpx;
					line-height: 90rpx;
					text-align: center;
					background-color: #F8F8F8;
					font-size: 28rpx;
					color: #666;
					border-right: solid 1px #faf7fa;
					&:last-child{
						border-right: none;
					}
					&.active{
						background-color: #FFF;
						color: #141414;
						font-weight: bold;
					}
				}
			}
		}
		.skill{
			padding: 30rpx;
			.skill-tit{
				display: flex;
				align-items: center;
				justify-content: space-between;
				.count-down{
					display: flex;
					align-items: center;
					.label{
						color: #141414;
						font-weight: bold;
						font-size: 36rpx;
						margin-right: 10rpx;
					}
				}
				.more{
					color: #808080;
				}
			}
			.skill-items{
				display: flex;
				align-items: center;
				.skill-item{
					width: 210rpx;
					margin-right: 28rpx;
					margin-top: 30rpx;
					image{
						width: 210rpx;
						height: 210rpx;
						background-color: #F29100;
						border-radius: 8rpx;
					}
					.price{
						margin-top: 10rpx;
						font-size: 22rpx;
						color: #F59359;
						font-weight: bold;
						text{
							font-size: 28rpx;
						}
					}
					.sub-price{
						text-decoration: line-through;
						color: #909090;
						font-size: 22rpx;
					}
				}
			}
		}
	}
</style>